<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
   	<!--Begin Header Begin-->
	
	<div class="m_top_bg">
		<div class="top">
			<div class="m_logo">
				<a href="Index.html"><img src="/EasyBuy/statics/images/logo1.png" />
				</a>
			</div>
			<div class="m_search">
				<form>
					<input type="text" value="" class="m_ipt" /> <input type="submit"
						value="搜索" class="m_btn" />
				</form>
				<span class="fl"><a href="#">咖啡</a><a href="#">iphone 6S</a><a
					href="#">新鲜美食</a><a href="#">蛋糕</a><a href="#">日用品</a><a href="#">连衣裙</a>
				</span>
			</div>
		<div class="i_car" id="buyCarCount">
			<div class="car_bg" id="product">
				<c:choose>
					<c:when test="${ empty applicationScope.id}">
						<div class='un_login'>
							还未登录！<a href='/EasyBuy/pre/Login.jsp' style='color:#ff4e00;'>马上登录</a>
							查看购物车！"
						</div>
					</c:when>
				</c:choose>

			</div>
		</div>
	</div>
	</div>
<script type="text/javascript" src="/EasyBuy/statics/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		//购物车总条数
		function cou(){
			$.get("IndexServlet","opr=seleCount&uId=${applicationScope.id}",function(data){
				$("#buyCarCount").append("<div class='car_t'>"+
				"购物车 [ <span>"+data+"</span> ]"+
				"</div>");
			});
		}
		cou();
		
		//购物车显示
		function product(){
			$.getJSON("IndexServlet","opr=productNPFinfo&userid=${applicationScope.id}",productcallBack);
		}
		function productcallBack(data){
			var $ulli=$("#product").html("");
			for(var i=0;i<data.length;i++){
				$ulli.append("<ul class='cars'>"+
				"<li>"+
					"<div class='img'>"+
						"<a href='#'><img src='/EasyBuy/statics/images/"+data[i].fileName+
							"' width='58' height='58' /> </a>"+
					"</div>"+
					"<div class='name'>"+
						"<a href='#'>"+data[i].name+"</a>"+
					"</div>"+
					"<div class='price'>"+
						"<font color='#ff4e00'>￥"+data[i].price+"</font> X"+data[i].productNum+
					"</div>"+
				"</li>"+
			"</ul>");
			if(i==data.length-1){
				$ulli.append("<div class='price_sum'>"+
				"共计&nbsp; <font color='#ff4e00'>￥</font><span>"+data[i].productZongSum+"</span>"+
			"</div>"+
			"<div class='price_a'>"+
				"<a href='/EasyBuy/pre/settlement/BuyCar.jsp'>去购物车结算</a>"+
			"</div>");
			}
			
			}
			
		}
		product();
	});
</script>